package com.polytech.dao;

import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;

import com.polytech.beans.Booking;
import com.polytech.beans.Car;

public class MemoryBookingDao implements BookingDao {

	private HashMap<String, Booking>bookings=new HashMap<>();
	@Override
	public void insert(Booking booking) {
		bookings.put(""+booking.getId(), booking);
	}
	@Override
	public Booking select(String key) {
		return bookings.get(key);
	}
	@Override
	public void remove(Booking booking) {
		if(bookings.containsKey(booking.getId()))
			bookings.remove(booking);
		
	}
	@Override
	public Collection<Car> selecetBookedCars() {
		List<Car> list=new LinkedList<Car>(); 
		for (Booking booking : bookings.values()) {
			list.add(booking.getCar());
		}
		return list;
	}
	@Override
	public Collection<Car> selecetNonBookedCars() {
		// TODO Auto-generated method stub
		return null;
	}
}
